﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Edit.Master" Inherits="System.Web.Mvc.ViewPage<Langben.DAL.ts_billmove>" %>

<%@ Import Namespace="Common" %>
<%@ Import Namespace="Models" %>
<asp:Content ID="Content4" ContentPlaceHolderID="CurentPlace" runat="server">
    修改 移库
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset>
        <legend>
            <input class="a2 f2" type="button"  value="打印预览" onclick="PrintPreview()"/>
            <input class="a2 f2" type="button"  value="打印" onclick="PrintForm()"/>
            <input class="a2 f2" type="button" onclick="BackList('ts_billmove')" value="返回列表" />
        </legend>
         <div class="bigdiv">
            <%: Html.HiddenFor(model => model.Id ) %>     
             <%: Html.HiddenFor(model => model.GoodsDetail)%> 
             <%: Html.HiddenFor(model => model.c_type) %>
             <%: Html.HiddenFor(model => model.i_sign)%>
              <fieldset style="width:850px"> 
             <table style="width:100%">
                <tr><td> <%: Html.LabelFor(model => model.i_no) %>：</td>
                <td> <%: Html.TextBoxFor(model => model.i_no, new {  onkeyup = "isInt(this)", @class="text-box single-line" })%>
            <%: Html.ValidationMessageFor(model => model.i_no) %></td>
            <td> <%: Html.LabelFor(model => model.c_orgno) %>：</td>
                <td><%: Html.EditorFor(model => model.c_orgno) %>
            <%: Html.ValidationMessageFor(model => model.c_orgno) %></td>
            <td><%: Html.LabelFor(model => model.dt_dt) %>：</td>
            <td> <%: Html.TextBox("dt_dt")%>
            <%: Html.ValidationMessageFor(model => model.dt_dt) %></td>
                </tr>
                <tr><td><%: Html.LabelFor(model => model.c_base1)%>：</td>
                <td colspan="3"> <%=Html.DropDownListFor(model => model.c_base1, Models.SysFieldModels.GetBaseInf(), "请选择")%></td>
                <td><%: Html.LabelFor(model => model.c_base2) %>：</td>
                <td> <%=Html.DropDownListFor(model => model.c_base2, Models.SysFieldModels.GetBaseInf(), "请选择")%>
                <%: Html.ValidationMessageFor(model => model.c_base2)%></td></tr>
                <tr><td> <%: Html.LabelFor(model => model.c_keeper1)%>：</td>
                <td> <%: Html.EditorFor(model => model.c_keeper1)%>
                <%: Html.ValidationMessageFor(model => model.c_keeper1)%></td>
                <td><%: Html.LabelFor(model => model.c_keeper2) %>：</td>
                <td> <%: Html.EditorFor(model => model.c_keeper2) %>
                <%: Html.ValidationMessageFor(model => model.c_keeper2) %></td>
                <td><%: Html.LabelFor(model => model.c_clerk) %>：</td>
                <td><%: Html.EditorFor(model => model.c_clerk) %>
                <%: Html.ValidationMessageFor(model => model.c_clerk) %></td></tr>
                <tr><td> <%: Html.LabelFor(model => model.c_comment) %>：</td>
                <td><%: Html.EditorFor(model => model.c_comment) %>
                <%: Html.ValidationMessageFor(model => model.c_comment) %></td>
                <td> <%: Html.LabelFor(model => model.c_audi) %>：</td>
                <td colspan="3"> <%: Html.EditorFor(model => model.c_audi) %>
                <%: Html.ValidationMessageFor(model => model.c_audi) %></td></tr>
                </table>  
                 </fieldset>
                 <div style="float:left;"> 
                 <div style="width:880px; height:350px"> 
                  <table id="flexigridData">
                  </table>

                 </div>  
              </div>
        </div>
    </fieldset>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
 <script src="../../Lodop/LodopFuncs.js" type="text/javascript"></script>
     <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0> 
	    <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0 pluginspage="install_lodop32.exe"></embed>
     </object> 
     

   <script type="text/javascript" language="javascript">

       var LODOP; //声明为全局变量 


       function prn1_preview(data) {
           LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
           LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_打印表格");

           //报表标题 
           LODOP.ADD_PRINT_HTM(30, 300, 330, 300, "<font color ='black' size ='4'>结账单查询</font>");
           //报表内容打印。 
           LODOP.ADD_PRINT_HTM(100, "5%", "90%", 314, data);
           LODOP.PREVIEW();
       };

       function prn1_print(data) {
           LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
           LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_打印表格");

           //报表标题 
           LODOP.ADD_PRINT_HTM(30, 300, 330, 300, "<font color ='black' size ='4'>结账单查询</font>");
           //报表内容打印。 
           LODOP.ADD_PRINT_HTM(100, "5%", "90%", 314, data);
           LODOP.PRINT();
       };

        $(function () {
            DoGrid();

            $('#i_no').attr("disabled", true);
            $('#dt_dt').attr("disabled", true);
            $('#c_base1').attr("disabled", true);
            $('#c_base2').attr("disabled", true);
            $('#c_orgno').attr("disabled", true);
            $('#c_keeper1').attr("disabled", true);
            $('#c_keeper2').attr("disabled", true);
            $('#c_clerk').attr("disabled", true);
            $('#c_audi').attr("disabled", true);
            $('#c_comment').attr("disabled", true);
            $('#flexigridGoodsData').datagrid({
                // title: '物品目录', //列表的标题
                iconCls: 'icon-site',
                width: 'auto',
                height: 'auto',
                nowrap: false,
                striped: true,
                singleSelect: true,
                collapsible: true,
                url: '../ts_goods/GetData', //获取数据的url
                sortName: 'Id',
                sortOrder: 'desc',
                idField: 'Id',

                toolbar: [
                     {
                         text: '选择',
                         iconCls: 'icon-ok',
                         handler: function () {
                             return flexiSelect();
                         }
                     }],
                columns: [[
                      { field: 'i_sign', title: '状态', width: 60 }
                	, { field: 'c_code', title: '编号', width: 80 }
				 	, { field: 'c_desc', title: '物品', width: 80 }
					, { field: 'c_model', title: '规格', width: 80 }
					, { field: 'c_unit', title: '单位', width: 80 }
					, { field: 'c_class', title: '类别', width: 80 }
					, { field: 'c_class1', title: '大类别', width: 52, hidden: true }
					, { field: 'f_pricelast', title: '最后进价', width: 52, hidden: true }
					, { field: 'f_upper', title: '库存上限', width: 60 }
					, { field: 'f_lower', title: '库存下限', width: 60 }
					, { field: 'c_py', title: '拼音', width: 52, hidden: true }
					, { field: 'c_comment', title: '备注', width: 52, hidden: true }
					, { field: 'c_vendor', title: '主供应商', width: 90 }
					, { field: 'c_base', title: '专用仓库', width: 90 }
                ]],
                pagination: true,
                rownumbers: true

            });

        });



        //打印预览
        function PrintPreview() {
            $.post("../../ts_billmove/PrintRK", { search: $("#Id").val() }, function (res) {
                prn1_preview(res.data);

            });
        }

        //直接开打印
        function PrintForm() {

            $.post("../ts_billmove/PrintRK", { search: $("#Id").val() }, function (res) {
                prn1_preview(res.data);

            });
        }



        function save() {
            var rows = $('#flexigridData').datagrid('getRows');
            var count = 0;
            var allrow = "";
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].Id == "" || rows[i].Id == null || rows[i].Id.toString() == "undefined") {

                    var row = JSON.stringify(rows[i]);
                    allrow = allrow + row + "^";
                }
            }

            $('#GoodsDetail').val(allrow);
            alert($('#GoodsDetail').val());
            $.ajax({
                url: this.action,
                type: "Post",
                data: $(document.forms[0]).serialize(),
                dataType: "json",
                success: function (data) {
                    if ($.messager) {
                        $.messager.defaults.ok = '继续';
                        $.messager.defaults.cancel = '返回';

                        $.messager.confirm('操作提示', data, function (r) {
                            if (!r) {
                                window.location.href = 'javascript:history.go(-1)';
                            }
                        });
                    }

                }
            });


        }



        //“选择”按钮，在其他（与此页面有关联）的页面中，此页面以弹出框的形式出现，选择页面中的数据
        function flexiSelect() {

            var rows = $('#flexigridGoodsData').datagrid('getSelections');
            if (rows.length == 0) {
                $.messager.alert('操作提示', '请选择数据!', 'warning');
                return false;
            }
            var indexs = 0;
            for (var i = 0; i < rows.length; i++) {

                indexs = i;
                $('#flexigridData').datagrid('insertRow', {
                    index: indexs,
                    row: {
                        c_code: rows[i].c_code,
                        c_desc: rows[i].c_desc,
                        c_model: rows[i].c_model,
                        c_unit: rows[i].c_unit,
                        f_price: rows[i].f_pricelast
                    }
                });
                $('#flexigridData').datagrid('selectRow', indexs);
                $('#flexigridData').datagrid('beginEdit', indexs);
            }
            $('#divQuery').dialog("close"); 
        }



        function DoGrid() {
            $('#flexigridData').datagrid({
                iconCls: ' ',
                width: 'auto',
                height: 'auto',
                nowrap: false,
                striped: true,
                fit: true,
                collapsible: true,
                url: '../../ts_billmovedetail/GetDataByi_no?i_no=' + $("#Id").val(), //获取数据的url
                sortName: 'Id',
                sortOrder: 'desc',
                idField: 'Id',

//                toolbar: [ 
//                   {
//                       text: '创建',
//                       iconCls: 'icon-add',
//                       handler: function () {
//                           return insert();
//                       }
//                   }],
                columns: [[
					  { field: 'c_code', title: '编号', width: 80 }
					, { field: 'c_desc', title: '品名', width: 200 }
					, { field: 'c_model', title: '规格', width: 160 }
                    , { field: 'c_unit', title: '单位', width: 65 }
                    , { field: 'f_quant', title: '数量', width: 80 }
                    , { field: 'f_price', title: '单价', width: 80 }
                    , { field: 'f_amount', title: '金额', width: 80 }
                    , { field: 'c_comment', title: '备注', width: 120} 
                ]],
                onBeforeEdit: function (index, row) {
                    row.editing = true;
                    updateActions();
                },
                onAfterEdit: function (index, row) {
                    row.editing = false;
                    updateActions();
                },
                onCancelEdit: function (index, row) {
                    row.editing = false;
                    updateActions();
                },

                pagination: true,
                rownumbers: false

            });

        }

        function updateActions() {
            var rowcount = $('#flexigridData').datagrid('getRows').length;
            for (var i = 0; i < rowcount; i++) {
                $('#flexigridData').datagrid('updateRow', {
                    index: i,
                    row: { action: '' }
                });
            }
        }

        function saverow(index) {

            $('#flexigridData').datagrid('endEdit', index);


        }


        function editrow(index) {
            $('#flexigridData').datagrid('beginEdit', index);
        }

        function deleterow(index) {
            $.messager.confirm('操作提示', '确定删除吗?', function (r) {
                if (r) {
                    $('#flexigridData').datagrid('deleteRow', index);
                }
            });
        }

        function cancelrow(index) {
            $('#flexigridData').datagrid('cancelEdit', index);
        }

        function insert() {

            $('#divQuery').dialog("open");
             
        }


    </script>
</asp:Content>

